package com.qianxun.module.datasource1.admin.view;

import com.qianxun.module.datasource1.admin.util.SysUserUtil;
import com.qianxun.module.base.view.BaseViewController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author: huwei
 * @date: 2019/11/13 15:05
 * @version: 1.0.0
 */
@Controller
@RequestMapping(value = {"/admin/user"})
public class SysUserViewController extends BaseViewController {
    private static final String  VIEW_PAGE_PREFIX = "module/admin/sysUser";

    @Override
    protected String prefix() {
        return VIEW_PAGE_PREFIX;
    }

    @RequestMapping(value = {"/menu/role/assign"})
    public ModelAndView permission(ModelAndView modelAndView , Long id){
        modelAndView.setViewName(prefix().concat("/menuRoleAssign.html"));
        modelAndView.addObject("id" ,id);
        return modelAndView;
    }

    @RequestMapping(value = {"/function/role/assign"})
    public ModelAndView permission(ModelAndView modelAndView , String uuid ,long id){
        modelAndView.setViewName(prefix().concat("/functionRoleAssign.html"));
        modelAndView.addObject("uuid" ,uuid);
        modelAndView.addObject("id" ,id);
        return modelAndView;
    }

    @RequestMapping(value = {"/to/set/password"})
    public ModelAndView setPwd(ModelAndView modelAndView){
        modelAndView.setViewName(prefix().concat("/setPassword.html"));
        return modelAndView;
    }

    @RequestMapping(value = {"/to/data/lock/{id}"})
    public ModelAndView toDataLock(ModelAndView modelAndView ,@PathVariable("id") Long id){
        String dataKey = SysUserUtil.dataLockKey(id);
        modelAndView.addObject("dataKey" ,dataKey);
        modelAndView.setViewName("redirect:/admin/dataModifyLock/toDataLock");
        return modelAndView;
    }
}
